﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;

namespace Summerset.Isbndb.Books
{
    /// <summary>
    /// Represents information about a subject that a given publication is listed in.
    /// Additional information on the subject can be retrieved from the subjects collection.
    /// </summary>
    public sealed class BookElementSubject
    {

        // Example Element:
        // <Subject subject_id="television_broadcasting_of_news_united_states">
        //  Television broadcasting of news -- United States
        // </Subject>

        #region Constructor + Private Fields

        readonly XmlNode _subjectNode;

        /// <summary>
        /// Initializes a new instance of <see cref="BookElementSubject"/> with the provided xml element.
        /// </summary>
        /// <param name="subjectNode">The xml element that contains the underlying data for this instance.</param>
        public BookElementSubject(XmlNode subjectNode)
        {
            _subjectNode = subjectNode;
        }

        #endregion
        #region Properties

        /// <summary>
        /// Gets the ISBNdb-specific subject ID for this publication.
        /// </summary>
        public string SubjectId
        {
            get { return _subjectNode.Attributes["subject_id"].Value; }
        }

        /// <summary>
        /// Gets the free-form text that identifies this subject.  This value can be shown to users.
        /// </summary>
        public string SubjectText
        {
            get { return _subjectNode.InnerText; }
        }

        #endregion

    }
}
